home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / v9n19.arc / REPL.BAT < prev    next >
DOS Batch File  |  1990-10-13  |  2KB  |  47 lines

  1. [[REPL.BAT]]
  2.  
  3. @ECHO OFF
  4. IF '%3'=='' GOTO explain
  5. ECHO Now checking for valid parameters . . .
  6. ECHO %2 | FIND "%1" > XXXXXXXX.TMP
  7. REM Only if %2 contained %1 will the tempfile be
  8. REM non-empty.  DOS won't copy an empty file.  So
  9. REM if the second tempfile exists, %2 DID contain %1.
  10. COPY XXXXXXXX.TMP YYYYYYYY.TMP > NUL
  11. DEL XXXXXXXX.TMP > NUL
  12. IF EXIST YYYYYYYY.TMP GOTO BadParams
  13. ECHO Replacing "%1" with "%2" in files matching:
  14. ECHO %3 %4 %5 %6 %7 %8 %9
  15. :--------------------------------------------------
  16. ECHO Now creating DEBUG script. . .
  17. ECHO NTEMPEDLN.SCR > TEMPDEBG.SCR
  18. ECHO E CS:100 '1R%1' 1A '%2' 0D 0A 'E' 0D 0A 1A >> TEMPDEBG.SCR
  19. ECHO RCX >> TEMPDEBG.SCR
  20. ECHO 40 >> TEMPDEBG.SCR
  21. ECHO W >> TEMPDEBG.SCR
  22. ECHO Q >> TEMPDEBG.SCR
  23. :--------------------------------------------------
  24. ECHO Now creating EDLIN script . . .
  25. DEBUG < TEMPDEBG.SCR > NUL
  26. DEL TEMPDEBG.SCR
  27. ECHO Replacing "%1" with "%2" in files matching: > REPL.LOG
  28. ECHO %3 %4 %5 %6 %7 %8 %9 >> REPL.LOG
  29. :--------------------------------------------------
  30. ECHO Now performing replacement . . .
  31. FOR %%f IN (%3 %4 %5 %6 %7 %8 %9) DO EDLIN %%f < tempedln.scr >> REPL.LOG
  32. DEL TEMPEDLN.SCR
  33. ECHO To see a log of the work REPL.BAT did, read the file REPL.LOG
  34. GOTO end
  35. :BadParams
  36. DEL YYYYYYYY.TMP > NUL
  37. ECHO Unfortunately, the string "%2" _contains_
  38. ECHO the string "%1".  REPL.BAT can't handle that.
  39. GOTO end
  40. :Explain
  41. ECHO SYNTAX: "REPLACE findstr replacestr filespec [filespec...]
  42. ECHO This batch program will search files matching up to 7
  43. ECHO file specifications and replace all occurrences of the
  44. ECHO "find string" with the "replace string" in each file.
  45. :end
  46.  
  47.